public class Demo5 {
    public static void main(String[] args) throws InterruptedException{
        Thread mainThread=Thread.currentThread();
        Thread t=new Thread(() ->{
          while (true){
              try {
                  System.out.println("main state="+mainThread.getState());
                  Thread.sleep(1000);
              } catch (InterruptedException e) {
                  e.printStackTrace();
              }
          }
        });
        System.out.println(t.getState());
        t.start();

        //由于t线程是持续while 循环,因此 join不会返回
        //观察主线程的状态就能看见waiting
       // Thread.sleep(500);
        t.join();

      //  System.out.println(t.getState());
    }
}
